package com.qm.finger;


import com.qm.finger.protocol.FingerSdk;

import java.io.InputStream;

public class FingerManager {

    public static String TAG = FingerManager.class.getSimpleName();
    public static FingerManager mInstance = null;

    private FingerSdk lockerSdk;
    private InputStream mInputStream;

    public static FingerManager getInstance() {
        if (null == mInstance) {
            mInstance = new FingerManager();
        }
        return mInstance;
    }

    public InputStream Init(String sPort) {
        lockerSdk = new FingerSdk();
        return lockerSdk.Init(sPort);
    }

    //获取串口输入流
    public InputStream getInputStream() {
        if (lockerSdk != null) {
            return lockerSdk.getInputStream();
        } else {
            return null;
        }
    }

    //发送采集指纹-1开始指令
    public int startFinger_1(int userID) {
        if (lockerSdk == null)
            return -1;
        return lockerSdk.startFinger_1(userID);
    }

    //发送采集指纹-2开始指令
    public int startFinger_2(int userID) {
        if (lockerSdk == null)
            return -1;
        return lockerSdk.startFinger_2(userID);
    }

    //发送采集指纹-3开始指令
    public int startFinger_3(int userID) {
        if (lockerSdk == null)
            return -1;
        return lockerSdk.startFinger_3(userID);
    }

    //获取用户数量
    public int getUserNum() {
        if (lockerSdk == null)
            return -1;
        return lockerSdk.getFingerUserNum();
    }
    //删除某个权限的所有用户
    public int deleteAllUserByRole(int role) {
        if (lockerSdk == null)
            return -1;
        return lockerSdk.deleteAllUser(role);
    }
    //删除指定用户
    public int deleteUser(int userID) {
        if (lockerSdk == null)
            return -1;
        return lockerSdk.deleteUser(userID);
    }
    //1:N比对用户特征值
    public int compareUser(){
        if (lockerSdk == null)
            return -1;
        return lockerSdk.compareUser();
    }
    //采集图像并提取特征值
    public int collectImgExtractF(){
        if (lockerSdk == null)
            return -1;
        return lockerSdk.collectImgExtractF();
    }
    //将指纹信息写入指纹模块
    public int registerUser(int userID,byte[] fingerData){
        if (lockerSdk == null)
            return -1;
        return lockerSdk.registerFinger(userID,fingerData);
    }
    public void unInit() {
        if (lockerSdk != null)
            lockerSdk.UnInit();
    }
}
